package com.ruoyi.newSystem.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.newSystem.domain.SystemKnowledgeRegister;
import com.ruoyi.newSystem.mapper.SystemKnowledgeRegisterMapper;
import com.ruoyi.newSystem.service.SystemKnowledgeRegisterService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 知识库注册表
 */

@Service
@Slf4j
@RequiredArgsConstructor
public class SystemKnowledgeRegisterServiceImpl implements SystemKnowledgeRegisterService {

    private final SystemKnowledgeRegisterMapper systemKnowledgeRegisterMapper;

    @Override
    public SystemKnowledgeRegister getSystemKnowledgeRegisterByMenuId(SystemKnowledgeRegister systemKnowledgeRegister) {
        QueryWrapper<SystemKnowledgeRegister> systemKnowledgeRegisterQueryWrapper = new QueryWrapper<>();
        systemKnowledgeRegisterQueryWrapper.eq("menu_id", systemKnowledgeRegister.getMenuId());
        return systemKnowledgeRegisterMapper.selectOne(systemKnowledgeRegisterQueryWrapper, false);
    }

    @Override
    public List<Map<String, Object>> getDataSet(String tableName) {
        return systemKnowledgeRegisterMapper.getDataSet(tableName);
    }

    @Override
    public List<SystemKnowledgeRegister> getSystemKnowledgeRegister() {
        QueryWrapper<SystemKnowledgeRegister> systemKnowledgeRegisterQueryWrapper = new QueryWrapper<>();
        systemKnowledgeRegisterQueryWrapper.select("DISTINCT knowledge_table", "name");
        return systemKnowledgeRegisterMapper.selectList(systemKnowledgeRegisterQueryWrapper);
    }


}
